﻿namespace OpenComposite.EII.Repository
{
	using System;
	using System.Collections.Generic;
	using System.Linq;
	using System.Messaging;
	using System.Text;
	using System.Windows.Forms;

	using OpenComposite.EII.Designer.Workflow.Forms;
	using OpenComposite.EII.RepositoryUIs;

	using OpenComposite.Repository.Properties;

	[RepositoryItem(ItemType.MessageQueue, "webservices", "websvc_id")]
	public class MessageQueueEx : WebService
	{
		#region Initialization

		/// <summary>
		/// Initializes a new instance of the <see cref="MessageQueueEx"/> class.
		/// </summary>
		/// <param name="bCreateNew">if set to <c>true</c> [b create new].</param>
		public MessageQueueEx(bool bCreateNew)
			: base(bCreateNew)
		{
		}

		/// <summary>
		/// Initializes a new instance of the <see cref="MessageQueueEx"/> class.
		/// </summary>
		/// <param name="id">The id.</param>
		public MessageQueueEx(int id)
			: base(id)
		{
		}

		/// <summary>
		/// Initializes a new instance of the <see cref="MessageQueueEx"/> class.
		/// </summary>
		public MessageQueueEx()
			: base()
		{
		}

		#endregion Initialization

		#region Public Members

		#region Properties

		/// <summary>
		/// Gets the image.
		/// </summary>
		/// <value>The image.</value>
		public override System.Drawing.Image Image
		{
			get { return Resources.messagequeue; }
		}

		/// <summary>
		/// Gets the image key.
		/// </summary>
		/// <value>The image key.</value>
		public override string ImageKey
		{
			get { return "messagequeue"; }
		}

		/// <summary>
		/// Gets or sets the path.
		/// </summary>
		/// <value>The path.</value>
		public string Path
		{
			get { return this.Uri; }
			set { this.Uri = value; }
		}

		/// <summary>
		/// Gets the queue.
		/// </summary>
		/// <value>The queue.</value>
		public MessageQueue Queue
		{
			get { return new MessageQueue(Path); }
		}

		/// <summary>
		/// Gets the type of the repository item.
		/// </summary>
		/// <value>The type of the repository item.</value>
		public override ItemType RepositoryItemType
		{
			get { return ItemType.MessageQueue; }
		}

		/// <summary>
		/// Gets the repository item type description.
		/// </summary>
		/// <value>The repository item type description.</value>
		public override string RepositoryItemTypeDescription
		{
			get { return "A Microsoft Message Queue."; }
		}

		/// <summary>
		/// Gets the name of the repository item type.
		/// </summary>
		/// <value>The name of the repository item type.</value>
		public override string RepositoryItemTypeName
		{
			get { return "Message Queue"; }
		}

		#endregion Properties

		#region Methods

		/// <summary>
		/// Shows the new item form.
		/// </summary>
		/// <param name="idRepository">The repository ID.</param>
		/// <param name="bAllowContinue">if set to <c>true</c> to allow save and continue.</param>
		/// <param name="parentItem">The parent item.</param>
		/// <param name="idDomain">The domain ID.</param>
		/// <param name="parentItemNew">The new parent item.</param>
		/// <returns></returns>
		public override DialogResult ShowNewItemForm(int idRepository, bool bAllowContinue, IRepositoryItem parentItem, ref int idDomain, out IRepositoryItem parentItemNew)
		{
			FormCreateNewMessageQueue form = new FormCreateNewMessageQueue(this, this, bAllowContinue);
			DialogResult result = form.ShowDialog();
			parentItemNew = form.ParentItem;
			idDomain = form.DomainID;
			return result;
		}

		#endregion Methods

		#endregion Public Members
	}
}